﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _3.Shapes
{
    class Shapes
    {
        static void Main()
        {
            Shape[] shape = 
            {
                new Rectangle(4,3),
                new Circle(2),
                new Triangle(3,4)
            };
            foreach (var item in shape)
            {
                Console.WriteLine(item.CalculateSurface());
            }
        }
    }
    abstract class Shape
    {
        private int width;
        private int height;
        public Shape(int w, int h)
        {
            width = w;
            height = h;
        }
        public int Width
        {
            get { return width; }
        }
        public int Height
        {
            get { return height; }
        }
        public abstract double CalculateSurface();
    }
    class Triangle : Shape
    {
        public Triangle(int w, int h)
            : base(w, h) { }
        public override double CalculateSurface()
        {
            return ((Width * Height) / 2);
        }
    }
    class Rectangle : Shape
    {
        public Rectangle(int w, int h)
            : base(w, h) { }
        public override double CalculateSurface()
        {
            return (Width * Height);
        }
    }
    class Circle : Shape
    {
        public Circle(int w)
            : base(w, w) { }
        public override double CalculateSurface()
        {
            return (Math.PI * Height * Height);
        }
    }
}
